package com.leyou.user.dto;


import com.leyou.dto.BaseDTO;
import com.leyou.user.entity.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserDto extends BaseDTO {

    private Long id;
    private String username;
    private String phone;


    public UserDto(User user) {
        super(user);
    }

    public static List<UserDto> convertEntityList(Collection<User> list) {
        return list
                .stream()
                .map(user->{
                    UserDto userDto = new UserDto(user);
                    return userDto;
                })
                .collect(Collectors.toList());
    }
/*    public static <T extends BaseEntity> List<UserDto> convertEntityList(Collection<T> list){
        return list.stream().map(UserDto::new).collect(Collectors.toList());
    }*/


}

